package com.ruoyi.project.poem.audiorecom.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.poem.audiorecom.domain.AudioRecom;
import com.ruoyi.project.poem.audiorecom.mapper.AudioRecomMapper;
import com.ruoyi.project.poem.audiorecom.service.IAudioRecomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 读诗推荐Service业务层处理
 *
 * @author shixiangwen
 * @date 2022-07-15
 */
@Service
@DataSource(DataSourceType.POEMBBS)
public class AudioRecomServiceImpl implements IAudioRecomService {
    @Autowired
    private AudioRecomMapper audioRecomMapper;

    /**
     * 查询读诗推荐
     *
     * @param id 读诗推荐ID
     * @return 读诗推荐
     */
    @Override
    public AudioRecom selectAudioRecomById(Long id) {
        return audioRecomMapper.selectAudioRecomById(id);
    }

    /**
     * 查询读诗推荐列表
     *
     * @param audioRecom 读诗推荐
     * @return 读诗推荐
     */
    @Override
    public List<AudioRecom> selectAudioRecomList(AudioRecom audioRecom) {
        return audioRecomMapper.selectAudioRecomList(audioRecom);
    }

    /**
     * 新增读诗推荐
     *
     * @param audioRecom 读诗推荐
     * @return 结果
     */
    @Override
    public int insertAudioRecom(AudioRecom audioRecom) {
        audioRecom.setCreatedTime(DateUtils.getNowDate());
        return audioRecomMapper.insertAudioRecom(audioRecom);
    }

    /**
     * 修改读诗推荐
     *
     * @param audioRecom 读诗推荐
     * @return 结果
     */
    @Override
    public int updateAudioRecom(AudioRecom audioRecom) {
        return audioRecomMapper.updateAudioRecom(audioRecom);
    }

    /**
     * 删除读诗推荐对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteAudioRecomByIds(String ids) {
        return audioRecomMapper.deleteAudioRecomByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除读诗推荐信息
     *
     * @param id 读诗推荐ID
     * @return 结果
     */
    @Override
    public int deleteAudioRecomById(Long id) {
        return audioRecomMapper.deleteAudioRecomById(id);
    }
}
